package com.gzsxy.esjy.message.mds.encoder;

import com.alibaba.fastjson.JSON;
import com.gzsxy.esjy.message.mds.dto.MdsMessage;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageEncoder;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;

import java.util.List;

/**
 * mds编码器
 */
public class MdsEncoder extends MessageToMessageEncoder<MdsMessage> {

    @Override
    protected void encode(ChannelHandlerContext ctx, MdsMessage msg, List<Object> out) throws Exception {
        out.add(new TextWebSocketFrame(JSON.toJSONString(msg)));
    }
}
